package com.ldzy.config;

import com.ldzy.pojo.User;
import com.ldzy.service.IUserService;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class ResourcesInterceptor  implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        User user=(User) request.getSession().getAttribute("'USER_SESSION");
        String url=request.getRequestURI();
        System.out.println(url);
        if (user!=null)
            return true;
        if(url.indexOf("login")>=0)
            return  true;
//        request.setAttribute("msg","您还没有登录，请您登录！");
//        request.getRequestDispatcher("/user/login").forward(request,response);
        return true;
    }

}
